package cn.mw.cmdb.controller;

import cn.mw.cmdb.service.impl.CmdbServiceManage;
import cn.mw.cmdb.service.impl.InstanceViewImpl;
import cn.mw.cmdb.view.ViewManager;
import cn.mw.microMonitorCommon.api.common.BaseApiService;
import cn.mw.microMonitorCommon.api.common.ResponseBase;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@RequestMapping("/modelAppClient")
@Controller
@Tag(name = "app小程序接口")
@Slf4j
public class MwAppClientController extends BaseApiService {
    private CmdbServiceManage cmdbServiceManage;
    private ViewManager viewManager;
    private MessageSource messageSource;

    public MwAppClientController(CmdbServiceManage cmdbServiceManage, ViewManager viewManager
            , MessageSource messageSource) {
        this.cmdbServiceManage = cmdbServiceManage;
        this.viewManager = viewManager;
        this.messageSource = messageSource;
    }


    @PostMapping("/getInstanceNumByModel")
    @ResponseBody
    @Operation(summary = "根据模型统计实例数量")
    public ResponseBase getInstanceNumByModel() throws Exception {
        InstanceViewImpl viewService = (InstanceViewImpl) cmdbServiceManage.getModelService(InstanceViewImpl.ID);
        Object instanceNumByModel = viewService.getInstanceNumByModel();
        return setResultSuccess(instanceNumByModel);
    }

}
